// 1 引入第三方包的一些方法,帮助我们创建路由
import { createRouter,createWebHashHistory } from "vue-router";

// 创建路由表
const routes = [
  {
    // 路由地址
    path:"/cart",
    name:'cart',
    // 对应路由显示组件
    component: () => import("../views/cart.vue")
  },
  {
    path:"/home",
    name:'home',
    component: () => import("../views/home.vue")
  },
  {
    path:"/login",
    name:'login',
    component: () => import("../views/login.vue")
  },
  {
    path:"/banner",
    name:'banner',
    component: () => import("../views/banner/index.vue"),
    children:[
      {
        path:'bannerlist',
        name:'bannerlist',
        component:() => import('../views/banner/components/bannerList.vue')
      },
      {
        path:'addbanner',
        name:'addbanner',
        component:() => import('../views/banner/components/addBanner.vue')
      }
    ]
  }
]

// 2 创建一个路由实例
const router = createRouter({
  // 确定路由模式,当前使用hash模式
  history:createWebHashHistory(),
  // 定义路由表
  routes
})

// 3 导出当前路由实例
export default router